<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>我的医院医生管理</title>
<link rel="shortcut icon" href="favicon.ico">
<link href="${pageContext.request.contextPath }/bootstrapStyle/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
<link href="${pageContext.request.contextPath }/bootstrapStyle/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
<link href="${pageContext.request.contextPath }/bootstrapStyle/css/animate.min.css" rel="stylesheet">
<link href="${pageContext.request.contextPath }/bootstrapStyle/css/style.min.css?v=4.0.0" rel="stylesheet">
<link href="${pageContext.request.contextPath }/bootstrapStyle/css/plugins/treeview/bootstrap-treeview.css" rel="stylesheet">
</head>
<body class="gray-bg">
    <div class="row wrapper wrapper-content animated fadeInRight">
    	<div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>医院部门树-详情</h5>
                </div>
                <div class="ibox-content">
                    <p>该树实现对医院端部门及其医生的管理，实现树形可视化，逻辑化管理</p>
                </div>
            </div>
        </div>
        <div class="col-sm-3">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>医院科室</h5>
                </div>
                <div class="ibox-content">
                    <p>该树实现对医院端部门及其医生的管理，实现树形可视化，逻辑化管理</p>
                </div>
                <div class="ibox-content">
                    <div id="Dept_Tree" class="test">
                    	
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-9">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>预览信息1</h5>
                </div>
                <div class="ibox-content">
                    <p>这里预览的是每个科室的详细信息</p>
                </div>
                <div class="ibox-content">
                	<div id="ShowDetail" class="">
                    	
                    </div>
                </div>
            </div>
        </div>
        <div class="col-sm-9">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>预览信息2</h5>
                </div>
                <div class="ibox-content">
                    <p>这里预览的是各个科室的医生信息</p>
                </div>
                <div class="ibox-content">
                	<div class="wrapper wrapper-content animated fadeInRight">
        				<div class="row">
        					<div id="ShowDoctors" class="">
        						
        					</div>
                    	</div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script src="${pageContext.request.contextPath }/bootstrapStyle/js/jquery.min.js?v=2.1.4"></script>
    <script src="${pageContext.request.contextPath }/bootstrapStyle/js/bootstrap.min.js?v=3.3.5"></script>
    <script src="${pageContext.request.contextPath }/bootstrapStyle/js/content.min.js?v=1.0.0"></script>
    <script src="${pageContext.request.contextPath }/bootstrapStyle/js/plugins/treeview/bootstrap-treeview.js"></script>
    <script type="text/javascript">
    $(function () {
		// Some logic to retrieve, or generate tree structure
		var nodes=[];//父节点
		var tnodes=[];//总的子节点
		//var str="[";
		$.ajax({
		type:"post",
		url:"${pageContext.request.contextPath}/Main/myinfo/mydoctormanCheck.action",
		contentType:"application/json;charset=utf-8",
		async: true,
		success:function(data){
			for(var i = 0;i < data.length;i++){
				if(data[i].hospdeptfatherid!=0){
					var rows = data[i];
    					tnodes.push({
    						id:rows.hospdeptid,
    						nodeid:rows.hospdeptfatherid,
    						text:rows.hospdeptname
    					});
    				}
    			}
    			//alert(tnodes[20].id);
    			for(var i = 0;i < data.length;i++){
    				var tnodeskey=[];//分段子节点
    				//构造父节点
    				if(data[i].hospdeptfatherid==0){
    					//str+="{text:"+' "'+data[i].hospdeptname+'"'+",id:"+"'"+data[i].hospdeptid+"'"+"},"
    					var row = data[i];
    					var count=0;	
    					for(var j=0;j<tnodes.length;j++){
    						if(tnodes[j].nodeid==row.hospdeptid){
    							tnodeskey.push({
    		    					id:tnodes[j].id,
    		    					text:tnodes[j].text
    		    				});
    							count++;
    						}
    					}
    					nodes.push({//分段加载父节点和子节点
	    					id:row.hospdeptid,
	    					text:row.hospdeptname,
	    					tags:[count],//加载子节点的个数，在每个li标签的后面显示数字
	    					nodes:tnodeskey
	    				});
    				}
    			}
    			//str=(str.substring(str.length-1)==',')?str.substring(0,str.length-1):str;
    			//str+="]";
    			//alert(str);
    			function getTree(){
    				var StrNode=nodes;
    				//alert(nodes);
    	            //var data=[{text: "祖宗节点1",id:'1'},{text: "祖宗节点2",id:'2',nodeId:'1'}];
    	            //alert(str1);
    	            return StrNode;
    	        }
    			$('#Dept_Tree').treeview({
    		        data: getTree(),         // data is not optional
    		        color:"#428bca",
    		        levels: 1,
    		        multiSelect: true,
    		        showTags:!0,
    		        nodeIcon: 'glyphicon glyphicon-user',
    		        emptyIcon: '', //没有子节点的节点图标
    		        onNodeChecked: function (event,data) {
    		        	//alert("onNodeChecked:"+data.id);
    		        },
    		        onNodeSelected: function (event, dataSource) {//选中节点事件
    		        	//alert("onNodeSelected:"+data.id);
    		        	//$('#ShowDetail')[0].innerHTML="获取的部门hospdeptid是："+dataSource.id;
    		        	$.ajax({
    		        		type:"post",
    		        		url:"${pageContext.request.contextPath}/Main/myinfo/hospdeptdoctors.action",
    		        		contentType:"application/json;charset=utf-8",
    		        		async: true,
    		        		data:'{"docdept":"'+dataSource.id+'"}',
    		        		success:function(data){//查询成功返回数据显示
    		        			$('#ShowDetail')[0].innerHTML="";
    		        			$('#ShowDoctors')[0].innerHTML="";//上面这两个不可丢失，实现对换标签点击的时候清楚预览版的内容，防止append的内容合到一起
    		        			//$('#ShowDetail')[0].innerHTML="获取的部门详情信息是："+data.hospdeptabs;
    		        			//$('#ShowDoctors')[0].innerHTML="<a>"+data.hospdeptabs+"</a>";
    		        			$('#ShowDetail').append("获取的部门详情信息是："+data[0].hospdeptabs);
    		        			for(var i=0;i<data.length;i++){
        		        			$('#ShowDoctors').append("<div class="+'"col-sm-4"'+">"+
        		        	                	"<div class="+'"contact-box"'+">"+
        		                    				"<a data-toggle="+'"modal"'+" href="+'"#modal-form"'+">"+
        		                        				"<div class="+'"col-sm-3"'+">"+
        		                            				"<div class="+'"text-center"'+">"+
        		                                				"<img alt="+'"image"'+" class="+'"img-circle m-t-xs img-responsive"'+" src="+'"${pageContext.request.contextPath}/bootstrapStyle/img/a2.jpg"'+">"+
        		                                				"<div class="+'"m-t-xs font-bold"'+"><i class="+'"fa fa-user"'+"></i> 姓名："+data[i].docname+"</div>"+
        		                            				"</div>"+
        		                        				"</div>"+
        		                        				"<div class="+'"col-sm-9"'+">"+
        			                        				"<div class="+'"row"'+">"+
				        			                        	"<p><i class="+'"fa fa-whatsapp"'+"></i> 联系电话：18156493238</p>"+
				        										"<hr/>"+
				        										"<p><i class="+'"fa fa-hospital-o"'+"></i> 所属医院："+data[i].hospname+"</p>"+
				        										"<hr/>"+
				        										"<p><i class="+'"fa fa-bank"'+"></i> 所属科室："+data[i].hospdeptname+"</p>"+
				        										"<hr/>"+
				        			                        	"<div class="+'"col-sm-6"'+">"+
        										    				"<p><i class="+'"fa fa-child"'+"></i> 年龄："+data[i].docage+"</p>"+
        			                        					"</div>"+
        			                        					"<div class="+'"col-sm-6"'+">"+
        									        				"<p><i class="+'"fa fa-intersex"'+"></i> 性别："+data[i].docmale+"</p>"+
        			                        					"</div>"+
        			                        				"</div>"+
        		                        				"</div>"+
        		                        				"<div class="+'"clearfix"'+"></div>"+
        		                    				"</a>"+
        		                				"</div>"+
        		            				"</div>");
    		        			}
    		        		},
    		        		error: function(request) {//查询失败，显示数据查询错误！
    		        			$('#ShowDetail')[0].innerHTML="";
    		        			$('#ShowDoctors')[0].innerHTML="";
    		        			$('#ShowDetail').append(" <a style="+'"color:red"'+"><abbr title="+'"提示"'+">数据查询延迟，重试！！！</abbr></a>");
    		        			$('#ShowDoctors').append(" <a style="+'"color:red"'+"><abbr title="+'"提示"'+">数据查询延迟，重试！！！</abbr></a>");
    		                }
    		        	})
    		        }
    		    }).treeview('collapseAll', { silent: true });
    		}
    	});
    });
    /* function itemOnclick(target){//自定义点击li事件
    	//找到当前节点id  
        var nodeid = $(target).attr('data-nodeid');
    	var tree = $('#Dept_Tree');
    	$('#Show')[0].innerHTML=nodeid;
    	//获取当前节点对象  
		var node = tree.treeview('getNode', nodeid);
    	var node1=tree.treeview(true).methodName(args);
    	alert(node1);
    	if(node.state.checked){
    	    //处于展开状态则折叠  
    	    alert();
    	    tree.treeview('collapseNode', node.nodeId);    
    	} else {  
    	    //展开  
    	    alert();
    	    tree.treeview('expandNode', node.nodeId);  
    	}	
    } */
	</script>
	<!-- 这里的js屏蔽了三大查看网页源码的方式，包括右击查看、F12查看以及Ctlr+shift+I查看 -->
	 <!--  <script type="text/javascript">
          window.onload = function() {
              document.onkeydown = function() {
                 var e = window.event || arguments[0];
                 //屏蔽F12
                if(e.keyCode == 123) {
                    return false;
                 //屏蔽Ctrl+Shift+I
                 } else if((e.ctrlKey) && (e.shiftKey) && (e.keyCode == 73)) {
                     return false;
                     //屏蔽Shift+F10
                 } else if((e.shiftKey) && (e.keyCode == 121)){
                     return false;
                 }
             };
             //屏蔽右键单击
             document.oncontextmenu = function() {
                 return false;
             }
         }
     </script>  -->
</body>
</html>